<template>
  <el-card>
    <div slot="header" v-if="showTitle">
      <span>{{ appData.name }}</span>
    </div>
    <rva-search
        :requestParams="requestParams"
        :queryParams="queryParams"
        :viewId="appData.searchId"
        v-if="appData.searchId"
    ></rva-search>
    <rva-list
        :requestParams="requestParams"
        :queryParams="queryParams"
        :viewId="appData.listId"
        v-if="appData.listId"
    ></rva-list>
  </el-card>
</template>

<script>
import RvaSearchView from "@/components/rva/search";
import RvaListView from "@/components/rva/list";

import {loadCrud} from "@/api/rva/crud";

// import RvaListConfig from "@/components/rva/list/config";
// import Vue from "vue";
// Vue.component('rva-list-config', RvaListConfig)

export default {
  name: "RvaCrud",
  components: {
    "rva-search": RvaSearchView,
    "rva-list": RvaListView
  },
  props:['appId', 'requestParams', 'showTitle'],
  data() {
    return {
      // 应用元数据
      appData: {},
      // 遮罩层
      loading: true,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        // 显示搜索条件
        showSearch: true,
        trigger: 0
      }
    };
  },
  created() {
    this.loadAppData();
  },
  methods: {
    /** 查询模块列表 */
    loadAppData() {
      this.loading = true;
      loadCrud(this.appId).then(response => {
        this.appData = response.data;
        sessionStorage.setItem('rvaDevMode', this.appData.devMode);
        console.log('loadAppData success', this.appData);
        this.loading = false;
      });
    }
  }
};
</script>
